<template>
	<view class="cflex-c-c">
		<view v-if="list!=''" class="cflex-r" style="background-color: #FFFFFF;border-radius: 15rpx;margin-top: 20rpx;padding: 20rpx;width: 95%;line-height: 100rpx;justify-content: space-between;align-items: center;">
			<view>
				<text style="font-size: 40rpx;">{{list[0].banrName}}</text>
				<view style="font-size: 36rpx;color: #777777;">
					<text>{{list[0].code}}</text>
				</view>
			</view>
			
			<view style="margin-right: 10rpx;"><text style="background-color: #2869FE;padding: 10rpx 20rpx;border-radius: 10rpx;color: #fff;" @tap="delBankCard(list[0].id)">删除</text> </view>
			
		</view>
		
		<view class="cflex-c-c" style="position: fixed;bottom: 100rpx;background-color: #2869FE;border-radius: 15rpx;width: 95%;padding: 20rpx 0;font-weight: bold;color: #fff;" @tap="addBank()">添加</view>
		
		<u-modal v-model="show" show-cancel-button :content="content" @confirm = "goAddBankCard()"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '添加银行卡后不可修改，是否要添加？',
				show: false,
				list:[],
			}
		},
		onShow() {
			setTimeout(()=>{
				this.bankReq();
			},100)
		},
		onLoad() {
			
		},
		methods: {
			delBankCard(id){
				console.log(id);
				this.$request("worker/bankCard/delBank",{id:id}).then(res=>{
					console.log("删除======>",res);
					if(res.code==0){
						this.bankReq();
					}
				})
			},
			bankReq(){
				this.$request("worker/bankCard/bankCardList").then(res=>{
					console.log("请求数据======>",res);
					this.list = res.data;
				})
			},
			addBank(){
				if(this.list.length){
					uni.showToast({
						title:"已添加银行卡",
						icon:"none",
						duration:2000
					})
				}else {
					this.show = true;
				}
			},
			goAddBankCard(){
				uni.navigateTo({
					url:"./addBank"
				})
			}
		}
	}
</script>

<style>

</style>
